<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:include href="core\form.xsl"/>
	<xsl:include href="core\level-header.xsl"/>
	
<xsl:template match="page">
	<xsl:choose>
		<xsl:when test="//page/theme = 1"><xsl:call-template name="page_vert"/></xsl:when>
 		<xsl:otherwise><xsl:call-template name="page_horiz"/></xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="page_vert">
	<table cellspacing="0" cellpadding="0" width="100%" border="1">
		<tr>
			<td valign="top">
				<table cellspacing="2" cellpadding="2">
					<xsl:choose>
						<xsl:when test="//page/image/@align='center'">
							<xsl:if test="//page/image and contains(//page/image, 'jpg')">
								<tr>
									<td align="center">
										<img>
											<xsl:attribute name="src"><xsl:value-of select="$media_path"/><xsl:value-of select="image"/></xsl:attribute>
											<xsl:attribute name="align"><xsl:value-of select="image/@align"/></xsl:attribute>
											<xsl:attribute name="alt"><xsl:value-of select="image/@alt"/></xsl:attribute>
											<xsl:attribute name="vspace">10</xsl:attribute>
											<xsl:attribute name="hspace">10</xsl:attribute>
										</img>
									</td>
								</tr>
							</xsl:if>
							<tr><td><xsl:value-of select="info" disable-output-escaping="yes"/></td></tr>
						</xsl:when>
						<xsl:otherwise>
							<tr>
								<td>
									<xsl:if test="//page/image and contains(//page/image, 'jpg')">
										<img>
											<xsl:attribute name="src"><xsl:value-of select="$media_path"/><xsl:value-of select="image"/></xsl:attribute>
											<xsl:attribute name="align"><xsl:value-of select="image/@align"/></xsl:attribute>
											<xsl:attribute name="alt"><xsl:value-of select="image/@alt"/></xsl:attribute>
											<xsl:attribute name="hspace">10</xsl:attribute>
										</img>
									</xsl:if>
									<xsl:value-of select="info" disable-output-escaping="yes"/>
								</td>
							</tr>
						</xsl:otherwise>
					</xsl:choose>
				</table>
			</td>
		</tr>
	</table>
</xsl:template>

<xsl:template name="page_horiz">

</xsl:template>

<xsl:template match="rowset[@id='company_info']">
	<xsl:variable name="col_count" select="metadata/column-count"/>
	<hr width="100%" size="1" noshade="true" color="{$header_bg_color}"/>
	<table align="center" width="100%" cellspacing="2" cellpadding="2">
		<tr>
			<td>
				<table class="company_detail" cellspacing="6" width="100%" cellpadding="2" border="0" align="center">
					<tr>
						<xsl:for-each select="data/row">
							<xsl:variable name="rowId" select="col[1]"/>
							<xsl:if test="position() mod 3 = 1">
								<xsl:text disable-output-escaping="yes"><![CDATA[</tr><tr>]]></xsl:text>
							</xsl:if> 
							<td valign="top">
								<xsl:if test="position() >= 2">
									<table cellspacing="0" cellpadding="0" width="100%">
										<tr>
											<td>
												<nobr>
													<font class="flocation" color="{$color_main_first1}">
														<b>
															<xsl:if test="normalize-space(col[@name='city'])"><xsl:value-of select="col[@name='city']" disable-output-escaping="no"/>&#160;</xsl:if>Location
														</b>
													</font>
												</nobr>
											</td>
										</tr>
										<!--<tr>
											<td bgcolor="{$header_bg_color}" height="1">
												<img src="{$img_path_templates}/spacer.gif" width="1" height="1"/>
											</td>
										</tr>-->
									</table>
								</xsl:if>
								<xsl:if test="position() = 1">
									<table cellspacing="0" cellpadding="0" width="100%">
										<tr>
											<td>
												<nobr>
													<font class="flocation" color="{$color_main_first1}">
														<b>
															<xsl:if test="normalize-space(col[@name='city'])"><xsl:value-of select="col[@name='city']" disable-output-escaping="no"/>&#160;</xsl:if>Location
														</b>
													</font>
												</nobr>
											</td>
										</tr>
										<!--<tr>
											<td bgcolor="{$header_bg_color}" height="1">
												<img src="{$img_path_templates}/spacer.gif" width="1" height="1"/>
											</td>
										</tr>-->
									</table>
								</xsl:if>
								<table class="company_detail" cellspacing="1" cellpadding="1" width="100%">
								
									<tr valign="top">
										<td align="left" height="18" class="normaltext">
										
											<xsl:if test="normalize-space(col[@name='address'])">
												<nobr>
													<xsl:value-of select="col[@name='address']" disable-output-escaping="no"/><br/>
												</nobr>
											</xsl:if>
											<xsl:value-of select="col[@name='city']" disable-output-escaping="yes"/>
											<xsl:if test="normalize-space(col[@name='state'])"><nobr>,&#160;<xsl:value-of select="col[@name='state']" disable-output-escaping="yes"/></nobr></xsl:if>
											&#160;<xsl:value-of select="col[@name='zipcode']" disable-output-escaping="yes"/>
											<br/>
											<xsl:value-of select="col[@name='country']" disable-output-escaping="yes"/>&#160;
											<xsl:if test="normalize-space(col[@name='phone1'])">
												<br/>
												<nobr>
													<font class="titleblack">Phone:</font>&#160;
													<xsl:value-of select="col[@name='phone1']" disable-output-escaping="yes"/>
												</nobr>
												<xsl:if test="string-length(col[@name='phone1_ext'])>0">
													<br/>
													<nobr>
														&#160;ext.:&#160;<xsl:value-of select="col[@name='phone1_ext']" disable-output-escaping="yes"/>
													</nobr>
												</xsl:if>
											</xsl:if>
											<xsl:if test="normalize-space(col[@name='fax'])">
												<br/>
												<nobr>
													<font class="titleblack">Fax:</font>
													&#160;<xsl:value-of select="col[@name='fax']" disable-output-escaping="yes"/>
												</nobr>										
											</xsl:if>		
											<xsl:if test="normalize-space(col[@name='URL'])">
												<br/>
												<nobr>
													<font class="titleblack">Web:</font>&#160;
													<a target="_blank"><xsl:attribute name="href"><xsl:call-template name="make_url"><xsl:with-param name="url" select="col[@name='URL']"/></xsl:call-template></xsl:attribute><xsl:value-of select="col[@name='URL']" disable-output-escaping="yes"/></a>
												</nobr>										
											</xsl:if>			
										</td>
										
									</tr>
								</table>
							</td>
						</xsl:for-each>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</xsl:template>

<xsl:template name="compan_info_vert">
	<xsl:variable name="col_count" select="//page/rowset[@id='company_info']/metadata/column-count"/>
	<hr width="100%" size="1" noshade="true" color="{$header_bg_color}"/>
	<table align="center" width="100%" cellspacing="2" cellpadding="2">
		<tr>
			<td>
				<table class="company_detail" cellspacing="6" cellpadding="2" border="0" align="center">
					<tr>
						<xsl:for-each select="//page/rowset[@id='company_info']/data/row">
							<xsl:variable name="rowId" select="col[1]"/>
							<xsl:if test="position() mod 3 = 1">
								<xsl:text disable-output-escaping="yes"><![CDATA[</tr><tr>]]></xsl:text>
							</xsl:if> 
							<td valign="top">
								<xsl:if test="position() >=2">
									<table cellspacing="0" cellpadding="0" width="100%">
										<tr>
											<td>
												<nobr>
													<font class="flocation" color="{$color_main_first1}">
														<b>
															<xsl:if test="normalize-space(col[@name='city'])"><xsl:value-of select="col[@name='city']" disable-output-escaping="no"/>&#160;</xsl:if>Location
														</b>
													</font>
												</nobr>
											</td>
										</tr>
									</table>
								</xsl:if>
								<xsl:if test="position() =1">
									<table cellspacing="0" cellpadding="0" width="100%">
										<tr>
											<td>
												<nobr>
													<font class="flocation" color="{$color_main_first1}">
														<b>
															<xsl:if test="normalize-space(col[@name='city'])"><xsl:value-of select="col[@name='city']" disable-output-escaping="no"/>&#160;</xsl:if>Location
														</b>
													</font>
												</nobr>
											</td>
										</tr>
									</table>
								</xsl:if>
								<table class="company_detail" cellspacing="1" cellpadding="1" width="100%">
									
									<tr valign="top">
										<td align="left" height="18" class="normaltext">
										 <xsl:if test="normalize-space(col[@name='address'])">
												<nobr>
													<xsl:value-of select="col[@name='address']" disable-output-escaping="no"/>
													<br/>
												</nobr>
											</xsl:if>
											<xsl:value-of select="col[@name='city']" disable-output-escaping="yes"/>
											<xsl:if test="normalize-space(col[@name='state'])"><nobr>,&#160;<xsl:value-of select="col[@name='state']" disable-output-escaping="yes"/></nobr></xsl:if>
											&#160;<xsl:value-of select="col[@name='zipcode']" disable-output-escaping="yes"/>
											<br/>
											<xsl:value-of select="col[@name='country']" disable-output-escaping="yes"/>&#160;
											<xsl:if test="normalize-space(col[@name='phone1'])">
												<br/>
												<nobr>
													<font class="titleblack">Phone:</font>&#160;
													<xsl:value-of select="col[@name='phone1']" disable-output-escaping="yes"/>
												</nobr>
												<xsl:if test="string-length(col[@name='phone1_ext'])>0">
													<br/>
													<nobr>
														&#160;ext.:&#160;<xsl:value-of select="col[@name='phone1_ext']" disable-output-escaping="yes"/>
													</nobr>
												</xsl:if>
											</xsl:if>
											<xsl:if test="normalize-space(col[@name='fax'])">
												<br/>
												<nobr>
													<font class="titleblack">Fax:</font>&#160;
													<xsl:value-of select="col[@name='fax']" disable-output-escaping="yes"/>
												</nobr>										
											</xsl:if>		
											<xsl:if test="normalize-space(col[@name='URL'])">
												<br/>
												<nobr>
													<font class="titleblack">Web:</font>&#160;
<a target="_blank"><xsl:attribute name="href"><xsl:call-template name="make_url"><xsl:with-param name="url" select="col[@name='URL']"/></xsl:call-template></xsl:attribute><xsl:value-of select="col[@name='URL']" disable-output-escaping="yes"/></a>
													
												</nobr>										
											</xsl:if>			
										</td>
									</tr>
								</table>
							</td>
						</xsl:for-each>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</xsl:template>

<xsl:template name="contacts">
	<xsl:if test="normalize-space(col[@name='phone_work'])">
		<nobr>
			<font class="titleblack">Work phone:</font>
			<xsl:value-of select="col[@name='phone_work']"/>
		</nobr>
		<br/>
	</xsl:if>
	<xsl:if test="normalize-space(col[@name='phone_home'])">
		<nobr>
			<font class="titleblack">Home phone:</font>
			<xsl:value-of select="col[@name='phone_home']"/>
		</nobr>
		<br/>
	</xsl:if>
	<xsl:if test="normalize-space(col[@name='phone_cell'])">
		<nobr>
			<font class="titleblack">Cell phone:</font>
			<xsl:value-of select="col[@name='phone_cell']"/>
		</nobr>
		<br/>
	</xsl:if>
	<xsl:if test="normalize-space(col[@name='fax'])">
		<nobr>
			<font class="titleblack">Fax:</font>
			<xsl:value-of select="col[@name='fax']"/>
		</nobr>
		<br/>
	</xsl:if>
	<xsl:if test="normalize-space(col[@name='email'])">
		<nobr>
			<font class="titleblack">Email:</font>
			<xsl:value-of select="col[@name='email']"/>
		</nobr>
	</xsl:if>
</xsl:template>

<xsl:template name="address">
	<xsl:variable name="address">
		<xsl:if test="normalize-space(col[@name='address'])">
			<xsl:value-of select="concat(col[@name='address'],', ')"/>
		</xsl:if>
		<xsl:if test="normalize-space(col[@name='city'])">
			<xsl:value-of select="concat(col[@name='city'],', ')"/>
		</xsl:if>
		<xsl:if test="normalize-space(col[@name='state'])">
			<xsl:value-of select="concat(col[@name='state'],', ')"/>
		</xsl:if>
		<xsl:if test="normalize-space(col[@name='country'])">
			<xsl:value-of select="concat(col[@name='country'],', ')"/>
		</xsl:if>
	</xsl:variable>
	<xsl:if test="substring($address, string-length($address)-1, string-length($address)) = ', '">
		<xsl:value-of select="substring($address,1,string-length($address)-2)"/>
	</xsl:if>
	<xsl:if test="not(substring($address, string-length($address)-1, string-length($address)) = ', ')">
		<xsl:value-of select="$address"/>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>
